package com.baidu.uidgenerator.controller;

import com.baidu.uidgenerator.service.WorkerNodeService;
import com.xiaoju.uemc.tinyid.client.utils.TinyId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class WorkerNodeServiceController {

    @Autowired
    private WorkerNodeService workerNodeService;

    /**
     * 集成百度uid-generator生成id
     *
     * @return
     */
    @GetMapping("/baidu/uid")
    public long baiduUid() {
        long uid = workerNodeService.genUid();
        return uid;
    }


    /**
     * 集成百度uid-generator生成id
     *
     * @return
     */
    @GetMapping("/tinyId/uid")
    public long tinyId() {
        return TinyId. nextId( "test" );
    }
}